﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web_Oto.Business;
using Web_Oto.Common;

namespace Web_Oto.UC
{
    public partial class TopServices : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
                GetTopServices();
        }

        private void GetTopServices()
        {
            var showItem = int.Parse(ConfigurationManager.AppSettings["showTopNews"]);
            var serviceBus = new ConsultServiceBus();
            var listServices = serviceBus.GetTopServices(showItem);
            var sb = new StringBuilder();
            foreach (var listService in listServices)
            {
                sb.Append("<li>");
                sb.AppendFormat("<a href='/dich-vu-tu-van/{0}/{1}.html'>{2}</a>", CommonHelper.NiceUrl(CommonHelper.RemoveSpecialChars(listService.Name).Replace("  "," ")).ToLower(), listService.Id, listService.Name);
                sb.Append("</li>");
            }
            ltrTopServices.Text = sb.ToString();
        }
    }
}